package org.gvp.manager.repository.impl;

import lombok.RequiredArgsConstructor;

import org.gvp.manager.dto.MenuTreeData;
import org.gvp.manager.dto.NavigateMenuData;
import org.gvp.manager.pojo.SecurityUserMenu;
import org.gvp.manager.to.MapperUpdate;
import org.springframework.stereotype.Repository;
import org.gvp.manager.repository.SecurityUserMenuRepository;
import org.gvp.manager.mapper.SecurityUserMenuMapper;

import java.util.List;
/**
 * 用户菜单关系表 数据层接口实现类
 */
@Repository
@RequiredArgsConstructor
public class SecurityUserMenuRepositoryImpl implements SecurityUserMenuRepository {
    private final SecurityUserMenuMapper securityUserMenuMapper;

    @Override
    public List<String> searchUserMenuKeys(Integer userId) {
        return this.securityUserMenuMapper.selectUserMenuKeys(userId);
    }

    @Override
    public int logicalCancel(MapperUpdate update) {
        return this.securityUserMenuMapper.logicallyDelete(update);
    }

    @Override
    public List<MenuTreeData> searchMenuTreeByParentId(Integer parentId) {
        return this.securityUserMenuMapper.selectMenuTreeByParentId(parentId);
    }

    @Override
    public NavigateMenuData searchNavigateMenuById(Integer menuId) {
        return this.securityUserMenuMapper.selectNavigateMenuById(menuId);
    }

    @Override
    public List<NavigateMenuData> searchNavigateMenuByUserId(Integer userId) {
        return this.securityUserMenuMapper.selectNavigateMenuByUserId(userId);
    }

    @Override
    public List<MenuTreeData> searchNavigateMenuTreeData() {
        return this.securityUserMenuMapper.selectMenuTreeData();
    }

    @Override
    public List<Integer> searchMenuIds(List<String> keys) {
        return this.securityUserMenuMapper.selectMenuIds(keys);
    }
    @Override
    public SecurityUserMenu searchByUserIdAndRoleId(Integer userId, Integer menuId) {
        return this.securityUserMenuMapper.selectByUserIdAndMenuId(userId,menuId);
    }

    @Override
    public int recoverCancel(Integer id) {
        return this.securityUserMenuMapper.logicalRecovery(id);
    }

    @Override
    public int append(SecurityUserMenu pojo) {
       return this.securityUserMenuMapper.insert(pojo);
    }
}
